package br.com.fogas.medicao.activity;

import br.com.fogas.database.entidade.NotaFiscal;
import br.com.fogas.medicao.R;
import br.com.fogas.medicao.activity.helper.ImpressaoNotaHelper;
import br.com.fogas.medicao.application.Constants;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class ImpressaoNotaFragment extends Fragment {
	
	private NotaFiscal notaImpressao;
	private ImpressaoNotaHelper helper;
	
	public static final ImpressaoNotaFragment newInstance(NotaFiscal notaSimulacao) {
		Bundle bundle = new Bundle();
		bundle.putSerializable(Constants.NOTA_IMPRESSAO, notaSimulacao);
		ImpressaoNotaFragment fragment = new ImpressaoNotaFragment();
		fragment.setArguments(bundle);
		return fragment;
	} 
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.notaImpressao = (NotaFiscal) getArguments().getSerializable(Constants.NOTA_IMPRESSAO);
	}
	
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.impressao_nota, container, false);
        return view;
    }
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		this.helper = new ImpressaoNotaHelper(this, getView(), notaImpressao);
	}
	
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		this.helper.getNotaEngine().isActivityForResult(requestCode, resultCode, data);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
	}
	
	public ImpressaoNotaHelper getHelper() {
		return helper;
	}
}